<?php
$cid=$_GET['c'];
$config=$this->config->item('img_size');
$noimg=$this->config->item('noimg');
$nocontent=$this->config->item('nocontent');
$nodown=$this->config->item('nodown');
$listseo=$this->config->item('listseo');
?>
<div class="btn-group"><a href="<?php echo site_urlc('product/index');?>" class="btn"> <i class="fa fa-arrow-left"></i> <?php echo lang('back_list')?> </a></div>

<?php include_once 'inc_form_errors.php'; ?>

<div class="boxed">
    <h3> <i class="fa fa-pencil"></i> <?php echo lang('edit') ?> <span class="badge badge-success pull-right"><?php echo $title; ?></span></h3>
    <?php echo form_open(current_urlc(), array('class' => 'form-horizontal', 'id' => 'frm-edit')); ?>

    <div class="boxed-inner seamless">

        <div class="control-group">
            <label for="title" class="control-label"><?php echo lang('title') ?>:</label>
            <div class="controls">
                <input type="text" name="title" id="title" value="<?php echo set_value('title',$it['title']); ?>"  class='span7'>
                <span class="help-inline"></span>
            </div>
        </div>
        <?php if($cid==10):?>
        <div class="control-group">
            <label class="control-label" for="introduce"> 简介 </label>
            <div class="controls">
                <input type="text" id="introduce" name="introduce" class='span7' value="<?php echo set_value("introduce",$it['introduce']) ?>">
            </div>
        </div>
        <?php endif;?>
        <div class="control-group">
            <label class="control-label" for="borrow_price"> 借款金额 (万)</label>
            <div class="controls">
                <input type="text" id="borrow_price" name="borrow_price"  value="<?php echo set_value("borrow_price",$it['borrow_price']) ?>">
                <span class="help-inline">如：5~70 </span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="deadline"> 期限范围 (月)</label>
            <div class="controls">
                <input type="text" id="deadline" name="deadline"  value="<?php echo set_value("deadline",$it['deadline']) ?>">
                <span class="help-inline">如：12~60 </span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="credit"> 放款时间 (天)</label>
            <div class="controls">
                <input type="text" id="credit" name="credit"  value="<?php echo set_value("credit",$it['credit']) ?>">
                <span class="help-inline">如：3~5 </span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="min_interests"> 最低月利息</label>
            <div class="controls">
                <input type="text" id="min_interests" name="min_interests"  value="<?php echo set_value("min_interests",$it['min_interests']) ?>">
                <span class="help-inline">% </span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="max_interests"> 最高月利息</label>
            <div class="controls">
                <input type="text" id="max_interests" name="max_interests"  value="<?php echo set_value("max_interests",$it['max_interests']) ?>">
                <span class="help-inline">% </span>
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="repayment"> 还款方式</label>
            <div class="controls">
                <input type="text" id="repayment" name="repayment"  value="<?php echo set_value("repayment",$it['repayment']) ?>">
            </div>
        </div>
        <div class="control-group">
            <label class="control-label" for="virtual_num"> 申请成功人数</label>
            <div class="controls">
                <input type="text" id="virtual_num" name="virtual_num"  value="<?php echo set_value("virtual_num",$it['virtual_num']) ?>">
            </div>
        </div>
        <div class="control-group">
            <label for="title" class="control-label">时间:</label>
            <div class="controls">
                <div class="input-append date timepicker">
                    <input type="text" value="<?php echo date("Y/m/d H:i:s",set_value('timeline',$it['timeline'])); ?>" id="timeline" name="timeline">
                    <span class="add-on"><i class="icon-th"></i></span>
                </div>
            </div>
        </div>

        <!-- ctype -->
        <?php if ($ctype = list_coltypes($this->cid)) { ?>
            <div class="control-group">
                <label class="control-label" for="status"> 所属分类:</label>
                <div class="controls">
                    <?php
                    echo ui_btn_select('ctype',set_value("ctype",$it['ctype']),$ctype);
                    ?>
                    <span class="help-inline"></span>
                </div>
            </div>
        <?php } ?>

        <!-- 弹出 -->



        <?php if(!in_array($cid, $nocontent)):?>
            <div class="tabbable">
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#tab1" data-toggle="tab">申请条件</a></li>
                    <li><a href="#tab2" data-toggle="tab">所需材料</a></li>
                </ul>
                <div class="tab-content">
                    <div class="tab-pane active" id="tab1">
                        <div class="control-group uefull">
                            <textarea id="condition" name="condition"> <?php echo set_value('condition',$it['condition']); ?></textarea>
                        </div>
                    </div>
                    <div class="tab-pane" id="tab2">
                        <div class="control-group uefull">
                            <textarea id="material" name="material"> <?php echo set_value('material',$it['material']); ?></textarea>
                        </div>
                    </div>
                </div>
            </div>
        <?php endif;?>
        <?php if(!in_array($cid, $noimg)):?>
            <!-- 图片上传 -->
            <div class="control-group">
                <label for="img" class="control-label"><?php echo lang('photo') ?></label>
                <div class="controls">
                    <div class="btn-group">
                    <span class="btn btn-success">
                        <i class="fa fa-upload"></i>
                        <span> <?php echo lang('upload_file');
                            if (isset($config[$cid])) {
                                echo '【建议大小' . $config[$cid] . '】';
                            } else {
                                echo '【未定义】';
                            } ?> </span>
                        <input class="fileupload" type="file"  accept="" multiple="">
                    </span>
                        <input type="hidden" name="photo" class="form-upload" data-more="1" value="<?php echo $it['photo'] ?>">
                        <input type="hidden" name="thumb" id="thumb" class="form-upload-thumb" value="<?php echo $it['thumb'] ?>">
                    </div>
                </div>
            </div>
            <div id="js-photo-show" class="js-img-list-f"></div>
            <div class="clear"></div>
            <!-- 图片上传 -->
        <?php endif;?>
        <!-- 图片上传 -->

    </div>
    <div class="boxed-footer">
        <?php if ($this->ccid): ?>
            <input type="hidden" name="ccid" value="<?php echo $this->ccid ?>">
        <?php endif ?>
        <input type="hidden" name="cid" value="<?php echo $this->cid ?>">
        <input type="hidden" name="id" value="<?php echo $it['id']?>">
        <input type="submit" value="<?php echo lang('submit') ?>" class="btn btn-primary">
        <input type="reset" value="<?php echo lang('reset') ?>" class="btn btn-danger">
    </div>
    </form>
</div>

<?php include_once 'inc_ui_media.php'; ?>
<script type="text/javascript">
    require(['jquery','adminer/js/ui','adminer/js/media','bootstrap-datetimepicker.zh'],function($,ui,media){
        $('.timepicker').datetimepicker({'language':'zh-CN','format':'yyyy/mm/dd hh:ii:ss','todayHighlight':true});

        ui.editor_create('condition');
        ui.editor_create('material');
        media.init();

        var product_photos = <?php echo json_encode(list_upload($it['photo'])) ?>;
        media.show(product_photos,"photo");
        media.sort('photo');

    });
</script>
